import {defineConfig} from './build/vite';

import ElementPlus from 'unplugin-element-plus/vite';
import path from "path";

export default defineConfig(async () => {
    return {
        application: {},
        vite: {
            plugins: [
                ElementPlus({
                    format: 'esm',
                }),
            ],
            resolve: {
                alias: {
                    // 设置路径
                    '~': path.resolve(__dirname, './'),
                    // 设置别名
                    '@': path.resolve(__dirname, './src')
                },
                extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
            },
            server: {
                proxy: {
                    '/api': {
                        changeOrigin: true,
                        rewrite: (path) => path.replace(/^\/api/, ''),
                        // mock代理目标地址
                        target: 'https://mock-napi.vben.pro/api',
                        ws: true,
                    },
                },
            },
        },
    };
});
